package 蓝桥._2024.回文字符串;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int T = scan.nextInt();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < T; i++) {
            list.add(scan.next());
        }
        System.out.println(list);
        for (int i = 0; i < T; i++) {
            String s = list.get(i);
            System.out.println(s);
            int len = s.length();

            // 找到字符串从右往左的第一个不是l\q\b的字符
            int r = len - 1;
            while (r >= 0 && (s.charAt(r) == 'l' || s.charAt(r) == 'q' || s.charAt(r) == 'b')) {
                r--;
            }
            int l = 0;
            // 判断[l,r]是否是回文串
            while (l < r) {
                if (s.charAt(l) != s.charAt(r)) {
                    System.out.println("NO");
                    break;
                }
                l++;
                r--;
            }
            if (l >= r)
                System.out.println("YES");
        }

        scan.close();
    }
}